<template>
    <div >
        <el-container>
            <el-aside style="background-color: white;height:92.6vh" width="11vw">
                <el-scrollbar>
                    <el-menu :default-active="curRoute" @select="handleSelect">
                        <el-menu-item v-for="item in menuList" :key="item" :index="item.path" style="border-bottom: 1px solid #c5c5c5;">
                          <el-badge v-if="store.warnInventory.length!==0&&item.menu==='库存预警'" is-dot >
                            <span>{{item.menu}}</span>
                          </el-badge>
                          <span v-else>{{item.menu}}</span>
                        </el-menu-item>
                    </el-menu>
                </el-scrollbar>
            </el-aside>
            <el-main>
                <router-view/>
            </el-main>
        </el-container>
    </div>
</template>

<script setup>

import {onMounted, ref} from "vue";
import request from "@/utils/request";
import {store} from "@/store";
import router from "@/router";

const curMenu=ref("全部库存")
const curRoute=ref(router.currentRoute.value.path)
const menuList=[
    {
        menu:"全部库存",
        path:"/inventory/AllInventory"
    },
    {
        menu:"库存预警",
        path:"/inventory/WarnInventory"
    },
    {
        menu:"常进货商品",
        path:"/inventory/FrequentPurchase"
    },
    {
        menu:"进货入库",
        path:"/inventory/GoodsPurchase"
    },
    {
        menu:"库存记录",
        path:"/inventory/GoodsLog"
    },
    ]
onMounted(()=>{
    request.get("/goods/get/goodsInfo/"+store.getLocalCurrentStoreMain().storeId).then(res=>{
        store.goodsStoreInfoList=res.data
      store.warnInventory=store.goodsStoreInfoList.filter((p)=>{
        return p.state===1
      })
        console.log(store.goodsStoreInfoList)
        console.log(store.warnInventory)
    })

})

const handleSelect = (key) => {
  router.push(key)
}

</script>

<style scoped>
.el-menu-item.is-active {
  color: rgb(46, 126, 226) !important;
  font-weight: bold;
  border-right: 2px solid rgb(47, 125, 223);
}

</style>